'''
Created on 05/04/2013

@author: tsantana
'''

import os
import thilux_session
import thilux_security
import thilux_pages

from google.appengine.ext.webapp import template

def render_page(response, page, data={}):
    
    if thilux_session.is_user_logged():
        
        if not thilux_security.can_access(page):    
            page='NOT_AUTHORIZED_PAGE'
            
    else:
        page='INDEX_PAGE'
        
    path = os.path.join(os.path.dirname(__file__), thilux_pages.get_page(page))
            
    data['menus']=thilux_session.gen_menu_for_user()
            
    response.out.write(template.render(path, data))